<extend name="Common:base"/>
<block name="head">
  <style>
    .el-tabs__header{
      border-top:2px solid #ea4b4b;
      border-bottom: 1px solid #c51f1f;
    }
    .el-dialog .el-tabs__header{
      border-top:none;
    }
    .el-tabs--border-card .el-tabs__item{
      border-left: none;
    }
    .el-tabs--border-card .el-tabs__item.is-active {
      background-color: #fff;
      border-right-color: #d3dce6;
      background: #544b8f;
      color: #fff;
    }
    .el-tabs--border-card .el-tabs__header {
      background-color: #fff;
      margin: 0;
    }
    .container > .wrapp > .a > .el-row {
      margin-bottom: 6px;
    }
    .el-tabs--border-card .el-tabs__content{
      padding:0 9px 5px 9px;
    }
    .el-card, .el-menu--horizontal .el-submenu>.el-menu, .el-tabs--border-card{
      box-shadow: none;
    }
    .el-tabs--border-card{
      border: none;
    }
    .el-tabs__item{
    	font-family: Microsoft YaHei;
    	color:#0d0f10;
    	font-size: 14px;
    }
    .el-dialog__body{
      color: rgb(72, 87, 106);
      font-size: 14px;
      /*padding: 30px 20px;*/
      padding: 30px 20px 6px 20px;
    }
  </style>
</block>
<block name="body">
	<div id="app" class="container">
		<div class="wrapp" v-show="show" style="display:none;">
			<div class="a">
				<el-row>
        	<el-col :span="24">
          	<el-form :inline="true" ref="searchForm" :model="searchForm">
			  		  <el-form-item prop="type">
	              <el-select size="small" style="width:120px;" v-model="searchForm.type" 
                  placeholder="申请类型">
                  <el-option v-for="(value,key) in appType" :label="value" :value="key"></el-option>
	              </el-select>
			  		  </el-form-item>
			  		  
			  		  <el-form-item>
	              <el-select size="small" style="width:120px;" v-model="searchForm.check_status" 
                 placeholder="核查状态">
                  <el-option v-for="(value,key) in checkStatus" :label="value" :value="key"></el-option>
	              </el-select>
			  		  </el-form-item>
 
			  		  <el-form-item>
	              <el-select size="small" style="width:120px;" v-model="searchForm.app_status" 
                 placeholder="审批状态">
                  <el-option v-for="(value,key) in appStatus" :label="value" :value="key"></el-option>
	              </el-select>
			  		  </el-form-item>

	            <el-form-item prop="start">
                <el-date-picker size="small" v-model="searchForm.start" 
                  placeholder="选择开始日期范围"
                  type="daterange"
                  @change="startDateChange" style="width:210px;">
                </el-date-picker>
	            </el-form-item>
	            <el-form-item prop="end">
                <el-date-picker size="small"
                  v-model="searchForm.end" 
                  placeholder="选择截止日期范围" 
                  type="daterange"
                  @change="endDateChange" style="width:210px;">
                </el-date-picker>
	            </el-form-item>

	            <el-form-item>
	              <el-tooltip content="填写或者选择好筛选条件后点击此按钮" placement="bottom-start">
	                <el-button type="info" size="small" icon="search" @click="loadDatalist">查询</el-button>
	              </el-tooltip> 
	            </el-form-item>
             
              <el-form-item>
	              <el-tooltip content="清空搜索框并刷新表格数据" placement="bottom-start">
	                <el-button size="small" @click="resetBack">重置</el-button>
	              </el-tooltip>
              </el-form-item>

	            <el-form-item>
	              <el-tooltip content="点击刷新当前页面" placement="right">
	                <el-button @click="refresh" size="small" type="danger">刷新</el-button>
	              </el-tooltip>
	            </el-form-item>

            </el-form>
          </el-col>
			  </el-row>

			  <el-row>
        	<el-col :span="24">
	          <el-table v-loading="dataLoad" :data="dataList"
                @selection-change="handleChange"
                @row-dblclick = "showInfo"
	              element-loading-text="{:L('DATA_LOGIN')}"
	              empty-text="暂无数据!"
	              highlight-current-row ref="select" border>
              <el-table-column type="selection" width="55"></el-table-column>

			  	    <el-table-column label="{:L('INDEX')}" type="index" width="65" >
			  	    </el-table-column>

              
	            <el-table-column  align="center" prop="app_name" label="申请人" width="150">
	            </el-table-column>

              <el-table-column  align="center" prop="type" label="申请类型" width="100">
              	<template scope="scope">
					          {{ getType(scope.row.type, 'appType') }}
					        </template>
              </el-table-column>

			  	    <el-table-column  align="center" prop="reason" label="申请理由" show-overflow-tooltip >
			  	    	<template scope="scope">
                {{ scope.row.reason | handleString(6) }}
	            </template>
			  	    </el-table-column>

              <el-table-column  align="center" prop="app_time" label="申请时间" width="180px">
              </el-table-column>

              <el-table-column  align="center" prop="exp_time" label="期望交付日期" width="180px">
              </el-table-column>
							
							<el-table-column  align="center" prop="inspector" label="核查人员" width="150">
								<template scope="scope">
					          {{ getType(scope.row.inspector, 'userNames') }}
					        </template>
		          </el-table-column>
		          
		          <el-table-column  align="center" prop="approver" label="审批人员" width="150">
		          	<template scope="scope">
					          {{ getType(scope.row.approver, 'userNames') }}
					        </template>
		          </el-table-column>
		          
		          <el-table-column  align="center" prop="check_status" label="核查状态" width="150px">
                <template scope="scope">
                  <el-tag v-if="scope.row.check_status === '2'" type="primary">待核查</el-tag>
                  <el-tag v-else-if="scope.row.check_status === '1'" type="success">核查通过</el-tag>
                  <el-tag v-else="scope.row.check_status === '-1'" type="danger">核查不通过</el-tag>
                </template>
              </el-table-column>

              <el-table-column  align="center" prop="app_status" label="审批状态" width="150px">
                <template scope="scope">
                  <el-tag v-if="scope.row.app_status === '2'" type="primary">待审批</el-tag>
                  <el-tag v-else-if="scope.row.app_status === '1'" type="success">审批通过</el-tag>
                  <el-tag v-else="scope.row.app_status === '-1'" type="danger">审批不通过</el-tag>
                </template>
              </el-table-column>

			        <el-table-column align="center" prop="remark" label="备注" show-overflow-tooltip width="150px">
			        	<template scope="scope">
                {{ scope.row.remark | handleString(6) }}
	            </template>
              </el-table-column>
	          </el-table>
          </el-col>
			  </el-row>

			  <el-row>
			  	<el-col :span="12">
			      <div class="grid-content bg-purple">
              <span class="wrapper">
                <el-tooltip content="至少选择一条申请再点击取消申请" placement="bottom-start">
                  <el-button size="small" @click="handleDeletes" type="danger">取消申请</el-button>
                </el-tooltip>
                
              </span>
			      </div>
			    </el-col>
			  	<el-col :span="12" >
			      <div class="grid-content bg-purple-light pull-right">
			        <!-- page -->
			        <include file="Common:_pagination" />
			        <!-- / page -->
			      </div>
			    </el-col>
			  </el-row>
			</div>
			<div class="dialogWrapper" v-show="show" style="display: none">
			  <!-- 新增 -->
			  <include file="_add" />
		    <!-- / 新增 -->
        <!-- 展示行信息 -->
        <include file="_infoContents" />
        <!-- / 展示行信息 -->
			</div>
		</div>
	</div>
</block>
<block name="scripts">
<script>
	window.defaultOption.setDatas({
		multipleSelection: [],
		dialogLabelWidth:"120px",
		infoDialog:false,
    infoData:{},
    dataList:[],
    userNames:{:json_encode($userNames)},
    departmentType:{:json_encode($departmentType)},
    monthType:{:json_encode($monthType)},
    appType:{:json_encode($appType)},
    appStatus:{:json_encode($appStatus)},
    checkStatus:{:json_encode($checkStatus)},
    name:{:json_encode($name)},
    unit:{:json_encode($unit)},
    specification:{:json_encode($specification)},
    first:'first',
    
	}).setForm('search',{
		type:"",
    app_status:'',
    check_status:'',
    start:"",
    end:"",
	}).setMethod('resetBack',function(){
    window.location.href="{:U('index')}";
  }).setMethod('getType', function(type, field){
 		return this[field][type];
  }).setMethod('startDateChange', function(v){
    this.searchForm.start1 = v.slice(0,10);
    this.searchForm.start2 = v.slice(13);
  }).setMethod('endDateChange', function(v){
    this.searchForm.end1 = v.slice(0,10);
    this.searchForm.end2 = v.slice(13);
  }).setMethod('handleChange', function(val){
	  this.multipleSelection = val; //点击勾选用这个
		//点击选中用这个 开始
		/*this.deleteArrAllItem('multipleSelection');
		this.multipleSelection.push(val) ;*/
		//点击选中用这个 结束
	    
	}).setMethod("handleDeletes", function(url){
	  if(this.multipleSelection.length != 1){
		  this.$message.error('请选择一条信息');
		  return false;
	  }else{
		  if (!arguments[2]) {
			  url= this.page.deleteUrl;
		  }
		  var selectedIds = new Array();
		  for(var i=0; i<this.multipleSelection.length; i++){
			  selectedIds[i] = this.multipleSelection[i].id;
		  }
		  var vmThis = this;
		  this.$confirm('确定取消申请?', '提示', {
			  confirmButtonText: '确定',
			  cancelButtonText: '取消',
			  type: 'warning'
		  }).then(function(){
			  vmThis.$http.post(url, {ids:selectedIds}).then(function(response){
				  vmThis.$message({
					  type: 'success',
					  message: '取消成功!'
				  });
				  vmThis.loadDatalist();
			  }, function(response){
				  vmThis.$message({
					  type: 'error',
					  message: '取消失败'
				  });
			  })
		  }).catch(function() {
			  vmThis.$message({
				  type: 'info',
				  message: '已取消操作'
			  });
		  });
	  }

  }).setMethod('showInfo',function(row, event){
    this.infoData = row;
    this.infoDialog = true;
  });
</script>
</block>